home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / term-source.lha / termDebug.c < prev    next >
C/C++ Source or Header  |  1995-09-26  |  3KB  |  129 lines

  1. /*
  2. **    termDebug.c
  3. **
  4. **    Debugging support code
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. **
  9. **    :ts=4
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14. STATIC struct Screen    *DebugScreen;
  15. STATIC struct Window    *DebugWindow;
  16. STATIC struct RastPort    *DebugRPort;
  17.  
  18. VOID
  19. DebugExit()
  20. {
  21.     if(DebugWindow)
  22.     {
  23.         CloseWindow(DebugWindow);
  24.  
  25.         DebugWindow = NULL;
  26.     }
  27.  
  28.     if(DebugScreen)
  29.     {
  30.         CloseScreen(DebugScreen);
  31.  
  32.         DebugScreen = NULL;
  33.     }
  34. }
  35.  
  36. BOOL
  37. DebugInit()
  38. {
  39.     if(DebugScreen)
  40.         return(TRUE);
  41.     else
  42.     {
  43.         ULONG             DisplayID = DEFAULT_MONITOR_ID | HIRESLACE_KEY;
  44.         struct Screen    *PubScreen;
  45.  
  46.         if(PubScreen = LockPubScreen(NULL))
  47.         {
  48.             DisplayID = GetVPModeID(&PubScreen -> ViewPort);
  49.  
  50.             UnlockPubScreen(NULL,PubScreen);
  51.         }
  52.  
  53.         if(DebugScreen = OpenScreenTags(NULL,
  54.             SA_Depth,        1,
  55.             SA_Overscan,    OSCAN_TEXT,
  56.             SA_DisplayID,    DisplayID,
  57.             SA_Font,        &DefaultFont,
  58.             SA_Title,        "term Debug Screen",
  59.             SA_Behind,        TRUE,
  60.         TAG_DONE))
  61.         {
  62.             if(DebugWindow = OpenWindowTags(NULL,
  63.                 WA_CustomScreen,    DebugScreen,
  64.                 WA_Top,                DebugScreen -> BarHeight + 1,
  65.                 WA_Left,            0,
  66.                 WA_Width,            DebugScreen -> Width,
  67.                 WA_Height,            DebugScreen -> Height - (DebugScreen -> BarHeight + 1),
  68.                 WA_RMBTrap,            TRUE,
  69.                 WA_Backdrop,        TRUE,
  70.                 WA_Borderless,        TRUE,
  71.             TAG_DONE))
  72.             {
  73.                 DebugRPort = DebugWindow -> RPort;
  74.  
  75.                 return(TRUE);
  76.             }
  77.  
  78.             CloseScreen(DebugScreen);
  79.  
  80.             DebugScreen = NULL;
  81.         }
  82.  
  83.         return(FALSE);
  84.     }
  85. }
  86.  
  87. VOID
  88. DebugShowScrollInfo(VOID)
  89. {
  90.     UBYTE    LocalBuffer[256];
  91.     WORD    i,Left;
  92.  
  93.     for(i = 0 ; i < RasterHeight ; i++)
  94.     {
  95.         if(i == ScrollLineFirst)
  96.             SPrintf(LocalBuffer,"+%3ld %02lx",i,ScrollLines[i] . ColourMask);
  97.         else
  98.         {
  99.             if(i == ScrollLineLast)
  100.                 SPrintf(LocalBuffer,"-%3ld %02lx",i,ScrollLines[i] . ColourMask);
  101.             else
  102.                 SPrintf(LocalBuffer," %3ld %02lx",i,ScrollLines[i] . ColourMask);
  103.         }
  104.  
  105.         if(i == ScrollLineFirst || i == ScrollLineLast)
  106.             SetABPenDrMd(DebugRPort,0,1,JAM2);
  107.         else
  108.             SetABPenDrMd(DebugRPort,1,0,JAM2);
  109.  
  110.         Move(DebugRPort,0,DebugRPort -> TxBaseline + i * DebugRPort -> TxHeight);
  111.         Text(DebugRPort,LocalBuffer,strlen(LocalBuffer));
  112.  
  113.         Left = DebugRPort -> cp_x;
  114.  
  115.         SetABPenDrMd(DebugRPort,0,0,JAM1);
  116.         RectFill(DebugRPort,Left,i * DebugRPort -> TxHeight,DebugWindow -> Width - 1,(i + 1) * DebugRPort -> TxHeight - 1);
  117.  
  118.         if(ScrollLines[i] . Width)
  119.         {
  120.             SetAPen(DebugRPort,1);
  121.             SetAfPt(DebugRPort,(UWORD *)&Ghosting,1);
  122.  
  123.             RectFill(DebugRPort,Left + ScrollLines[i] . Left * 3,i * DebugRPort -> TxHeight,Left + ScrollLines[i] . Right * 3 - 1,(i + 1) * DebugRPort -> TxHeight - 1);
  124.  
  125.             SetAfPt(DebugRPort,NULL,0);
  126.         }
  127.     }
  128. }
  129.